class User(object):
    def __init__(self, name, age, city):
        self._name = name  # 受保护的变量，约定俗成不去修改，其实可以被修改掉
        self.__age = age  # 私有变量，python中不能访问
        self.city = city

    @property
    def age(self):
        return self.__age

    @age.setter
    def age(self, age):
        if isinstance(age, int):
            self.__age = age
        else:
            raise Exception('年龄只能是整数')


tom = User('tom', 20, 'LA.')
print(tom.age)
tom.age = 21
print(tom.age)